package cn.wolfcode.service.impl;

import cn.wolfcode.common.exception.BusinessException;
import cn.wolfcode.common.web.CommonCodeMsg;
import cn.wolfcode.domain.Product;
import cn.wolfcode.mapper.ProductMapper;
import cn.wolfcode.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;


@Service
public class ProductServiceImpl implements IProductService {
    @Autowired
    private ProductMapper productMapper;
    
    @Override
    public List<Product> queryProductByIds(List<Long> longs) {
        List<Product> products = productMapper.queryProductByIds(longs);
        if (StringUtils.isEmpty(products)){
            throw new BusinessException(CommonCodeMsg.NO_PRODUCT);
        }
        return products;
    }
    
    @Override
    public Product queryProductById(Long productId) {
        return productMapper.queryProductById(productId);
    }
}
